#!/bin/sh
trap - INT QUIT TERM
export PATH=/bin

if test -e /run/chronyd.pid; then
	pkill --pidfile /run/chronyd.pid
else
	echo "missing /run/chronyd.pid" 1>&2
fi

#if test -e /var/run/fcron.pid; then
#	pkill --pidfile /var/run/fcron.pid
#else
#	echo "missing /var/run/fcron.pid" 1>&2
#fi

#we used static configuration, hence no dhcp client
#dhcpcd --exit

#if test -e /var/run/syslog-ng.pid; then
#	pkill --pidfile /var/run/syslog-ng.pid
#else
#	echo "missing /var/run/syslog-ng.pid" 1>&2
#fi

udevadm control --exit
hwclock --utc --systohc

sync

if test "$(basename $0)" = "sysreboot"; then
  reboot -f
fi

poweroff -f
